<template>
  <div class="web">
    <div class="webLeft">
      <menuleft :menuList="menuList" @handleMenu="handleMenu" :menuFlag="showFlag" />
    </div>
    <div class="webRight">
      <projectAccounting @goManHour="goManHour" v-if="showFlag == '47'" />
      <manHourAccounting @goProject="goProject" :id="id" :period="period" :projectNames="projectNames" :projectNamess="projectNamess"
        v-if="showFlag == '2'" />
      <personnelAccounting v-if="showFlag == '48'" />
    </div>
  </div>
</template>

<script>
import projectAccounting from "./projectAccounting"; //项目核算
import personnelAccounting from "./personnelAccounting"; //个人核算
import manHourAccounting from "./manHourAccounting.vue";//查看工时
import { getUserAuthResourceList } from "@/service/Api.js"; //接口
import menuleft from "@/components/menuItem/menuleft.vue";
export default {
  components: {
    projectAccounting,
    personnelAccounting,
    manHourAccounting,
  },
  name: "projectMent",
  data() {
    return {
      menuList: [
        {
          name: "财务",
          id: 42,
          children: [],
        },
      ],
      showFlag: "",
      id: "",
      period: "",
      projectNames: "",
      projectNamess: ""
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      // 获取当前角色下的二级列表
      let menuId = parseInt(this.menuList[0].id)
      getUserAuthResourceList(menuId).then((res) => {
        if (res.code == 0) {
          this.menuList[0].children = res.data;
          if (this.id == "") {
            this.showFlag = res.data[0].id.toString();
          }
        } else {
          this.$message.error(`${res.data}`);
        }
      });
    },
    handleCommon(name, row, idx) {
      if (this[name]) {
        this[name](row, idx);
      }
    },
    handleMenu(id) {
      this.showFlag = id;
    },
    goManHour(a) {
      this.showFlag = "2";
      this.id = a.id;
      this.period = a.period;
      this.projectNames = a.projectNames;
      this.projectNamess = a.projectNamess;
    },
    goProject(id) {
      this.showFlag = "47";
      this.id = id;
    }
  },
};
</script>

<style scoped></style>
